<template>
  <div class="add-form">
    <el-dialog :title="titleInfo.text+titleInfo.pageTitle" :visible.sync="dialogFormVisible">
      <el-form
        :rules="ruleInline"
        ref="dataForm"
        :model="formBase"
        label-position="center"
        label-width="0"
        style=""
      >
        <el-form-item label="" prop="reason">
          <el-input
            type="textarea"
            :autosize="{ minRows: 6, maxRows: 6}"
            placeholder="请输入封禁意见"
            v-model="formBase.reason"
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button style="background-color:#F56C6C;border-radius:20px;color: #FFFFFF;"  @click="forbidden">提交</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { forbidden } from '@/api/xczx/courses'
export default {
  name: 'CourseForbidden',
  props: {
    titleInfo: {
      type: Object,
      required: true
    },
    formBase: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      dialogFormVisible: false,
      // 表单验证
      ruleInline: {
        reason: [{ required: true, message: '封禁意见不能为空', trigger: 'blur' }]
      }
    }
  },
  computed: {},
  methods: {
    // 弹层显示
    dialogFormV() {
      this.dialogFormVisible = true
    },
    // 弹层隐藏
    dialogFormH() {
      this.dialogFormVisible = false
    },
    // 课程封禁
    forbidden() {
      this.$refs['dataForm'].validate(async valid => {
        if (valid) {
          this.dialogFormH()
          let data = {
            'reason': this.formBase.reason
          }
          if (this.formBase.courseBaseId) {
            await forbidden(this.formBase.courseBaseId, data).then((res) => {
              this.$emit('forbidden')
            })
          }
        } else {
          this.$message.error('*号为必填项!')
        }
      })
    }
  },
  // 挂载结束

  mounted: function() {},
  // 创建完毕状态
  created() {
  },
  // 组件更新
  updated: function() {}
}
</script>
<style>
.el-form--label-left .el-form-item__label {
  text-align: right;
}
.el-form-item--medium {
  margin-bottom: 22px;
}
.el-dialog{
  width: 20%;
}

.el-dialog__footer {
  /* text-align: right; */
}
</style>
